<table width="1024" valign="top" border="0" align="center">
    <tr>
        <td height="720" valign="top">
            <table width="1024" class="borda">
                <tr>
                    <td>Digite um dado para busca:
                        <form id="form1" name="form1" method="post" action="?menu=visualizar_usuario">
                            <label>
                                <input type="text" size="60" name="texto" id="texto" />
                            </label>
                            <label> </label>
                            <input type="submit" name="buscar" id="buscar"  value="Buscar" />
                        </form></td>
                </tr>
                <tr>
                    <td height="120">
                        <?php
                        $nome = $_POST['texto'];
                        if (isset($nome)) {
                            require_once '../dao/FuncionarioDaoImp.class.php';
                            $dao = new FuncionarioDaoImp();
                            $result = $dao->buscarNome($nome);
                        ?>
                            <table width='1024' border="1">
                            <?php
                            foreach ($result as $row) {
                            ?>
                                <tr>
                                    <td><?php echo $row['idFuncionario'] ?> </td>
                                    <td><?php echo $row['nome'] ?> </td>
                                    <td><?php echo $row['cpf'] ?> </td>
                                    <td><?php echo $row['login'] ?> </td>
                                    <!-- func =  1 indica cadastrar, func = 2 indica alterar e 3 indica deletar e 4 visualizar-->
                                    <td><a href="?menu=visualizar_usuario&func=4&id=<?php echo $row['idFuncionario'] ?>">Visualizar</a> </td>
                                    <td><a href="?menu=visualizar_usuario&func=2&id=<?php echo $row['idFuncionario'] ?>">Alterar</a> </td>
                                    <td><a href="?menu=visualizar_usuario&func=3&id=<?php echo $row['idFuncionario'] ?>">Deletar</a> </td>
                                </tr>
                            <?php
                            }
                            ?>
                        </table>
                        <?php
                        }
                        ?>
                    </td>
                </tr>

            </table>
            <?php
                        $acao = $_GET['func'];
                        $id = $_GET['id'];
                        if (isset($acao) && isset($id)) {

                            require_once '../dao/FuncionarioDaoImp.class.php';
                            $dao = new FuncionarioDaoImp();
                            $result = $dao->buscarId($id);

                            
            ?>
                            <form name="form1" method="post" action="pages/daoFuncionario.php">
                                <input name="acao" id="acao" type="hidden" value="<?php echo $acao; ?>" />
                        <table width="1024" border="0" align="center">
                    <?php
                            foreach ($result as $row) {
                    ?>

                                <tr>
                                    <td width="187" height="43" align="right">C&oacute;digo</td>
                                    <td width="827" ><label>
                                            <input name="id" type="text" id="id" value="<?php echo $row['idFuncionario'] ?>" width="50" />
                                        </label></td>
                                </tr>
                                <tr>
                                    <td width="187" height="43" align="right">Nome</td>
                                    <td width="827" ><label>
                                            <input name="nome" type="text" id="nome" value="<?php echo $row['nome'] ?>" width="400" />
                                        </label></td>
                                </tr>
                                <tr>
                                    <td height="43" align="right">CPF*</td>
                                    <td ><label>
                                            <input name="cpf" type="text" id="cpf" value="<?php echo $row['cpf']; ?>" maxlength="11" />
                                        </label>
                                        (somente numeros)</td>
                                </tr>
                                <tr>
                                    <td height="43" align="right">RG*</td>
                                    <td ><label>
                                            <input name="rg" type="text" id="rg" maxlength="15" value="<?php echo $row['rg']; ?>"/>
                                        </label></td>
                                </tr>
                                <tr>
                                    <td height="43" align="right">Endereço</td>
                                    <td ><label>
                                            <input name="endereco" type="text"  id="endereco" value="<?php echo $row['endereco']; ?>" width="500" />
                                  </label></td>
                                </tr>
                                <tr>
                                    <td height="43" align="right">Fone 1</td>
                                    <td ><label>
                                            <input name="fone1" value="<?php echo $row['telefone1']; ?>" type="text" id="fone1" maxlength="11" />
                                        </label></td>
                                </tr>
                                <tr>
                                    <td height="43" align="right">Fone 2</td>
                                    <td ><label>
                                            <input name="fone2" type="text" id="fone2" value="<?php echo $row['telefone2']; ?>" maxlength="11" />
                                        </label></td>

                                </tr>
                                <tr>
                                    <td align="right">Usuário</td>
                                    <td><label>
                                            <input name="usuario" value="<?php echo $row['login']; ?>" type="text" id="usuario" size="40" />
                                        </label></td>
                                </tr>
                                <tr>
                                    <td align="right">Senha</td>
                                    <td><label>
                                            <input name="senha" value="<?php echo $row['senha']; ?>" type="password" id="senha" size="10" maxlength="10" />
                                        </label></td>
                                </tr>
                                <tr>
                                    <td>
									<?php
									
                            switch ($acao) {
                                case 2: {
                                        echo "<input type='submit' value='Alterar' />";
                                        break;
                                    }
                                case 3: {
                                        echo "<input type='submit' value='Deletar' />";
                                        break;
                                    }
                                default:break;
                            }
									?>
                                        
                                    </td>
                                </tr>

                    <?php
                            }
                    ?>

                        </table>
                    </form>
            <?php
                        }
            ?>
</table>